﻿using System;
using DomainModel.Domain.Model.MessageTypeModel;

namespace DomainModel.Domain.Model.ServiceModel
{
    public class HandlerRole : ServiceRole, IEquatable<HandlerRole>
    {
        public HandlerRole(ServiceRoleId id)
            : base(id)
        {         
        }

        public virtual MessageType HandledType { get; set; }        

        internal protected HandlerRole()
        {

        }

        public virtual bool Equals(HandlerRole other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return base.Equals(other) && Equals(other.HandledType, HandledType);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            return Equals(obj as HandlerRole);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (base.GetHashCode()*397) ^ (HandledType != null ? HandledType.GetHashCode() : 0);
            }
        }

     
    }
}